fix: #2463 update event handling for field-bitmap to support touch #2492
fix: #2463 update event handling for field-bitmap to support touch #2492RoboErikG merged 4 commits intoRaspberryPiFoundation:masterfrom
Conversation
…p to support touch This includes debug logging. A followup commit will remove the debugging.
|
Use |
|
Hi @mikeharv I made a fix to the bitmap editor based on your change. If you have some time would you mind taking a look to make sure I'm not missing anything? |
| * @param e The down event. | ||
| */ | ||
| private onPointerStart(e: PointerEvent) { | ||
| const currentElement = document.elementFromPoint(e.clientX, e.clientY); |
There was a problem hiding this comment.
Does e.target not work here?
There was a problem hiding this comment.
Touch events get captured by the element they start on. This means the target is always the element the event started on, so it won't change when you drag across another pixel cell.
|
For completeness, I did find an alternate to using elementFromPoint() would be to cast the target in the pointerdown event to an Element and call releasePointerCapture(). This might have a slight performance advantage, but both options work well so it's not worth revisiting unless we find an issue with the current approach. |
The basics
The details
Resolves
Fixes #2463 by changing how the editor handles mouse and touch events.
Proposed Changes
Updates the Bitmap field to properly support touch events. This change is based on code-dot-org/code-dot-org#61709 .
Screen.recording.2025-02-21.9.59.31.AM.webm
Reason for Changes
Touch events in the bitmap editor would get canceled by the browser, causing the gesture to end early and the state to not be cleaned up properly. This would cause Blockly to become partially unresponsive.
Test Coverage
Tested manually on a Chromebook with a touch screen.
Documentation
Additional Information